﻿@{
    ViewBag.Title = "SettingDetailForm";
    Layout = "~/Views/Shared/_LayoutIndex.cshtml";
}
<script>
    var Type = request('Type');
    var keyValue = request('keyValue');
    var Id = "@Guid.NewGuid().ToString()";
    var Level = request('Level');
    var Data = "";
    $(function () {
        initControl();
    })
    function initControl() {
        if (Type == 1) {
            $("#panel1").removeAttr("hidden");
            $("#panel2").attr("hidden", "hidden")
            $("#panel3").attr("hidden", "hidden")
            $("#Type").ComboBox({
                data: [{ "key": "1", "value": "选择型" }, { "key": "2", "value": "录入型" }],
                id: "key",
                text: "value",
                description: "==请选择==",
            })
            $("#Type").ComboBoxSetValue("1");
            $("#NeedFlag").ComboBox({
                data: [{ "key": "1", "value": "是" }, { "key": "0", "value": "否" }],
                id: "key",
                text: "value",
                description: "==请选择==",
            })
            $("#NeedFlag").ComboBoxSetValue("0");
            if (!!keyValue) {
                debugger;
                Data = top.frames["WorkAuditSettingForm"].$("#gridTable1").jqGridRow()[0];
                $("#Form1").SetWebControls(Data);

            } else {
                $("#FieldId").val(Id);
            }
        }
        if (Type == 2) {
            $("#panel2").removeAttr("hidden");
            $("#panel1").remove();
            $("#panel3").remove(); 
            var FieldNameData = top.frames["WorkAuditSettingForm"].top.frames["WorkAuditSetting"].$("#gridTable").jqGrid("getRowData");
            var data1 = [];
            data1.push({
                key:"AuditResult",
                value:"审核意见"
            });
            for (var i = 0; i < FieldNameData.length; i++) {
                if (!!FieldNameData[i].HandleConditionJson) {
                    var HandleConditionJson = JSON.parse(FieldNameData[i].HandleConditionJson)
                    for (var j = 0; j < HandleConditionJson.length; j++) {
                        data1.push({
                            key: HandleConditionJson[j].FieldId,
                            value: HandleConditionJson[j].FieldName
                        });
                    }
                }
            }
            $("#Loginc").ComboBox({
                data: [{ "key": "and", "value": "and" }, { "key": "or", "value": "or" }],
                id: "key",
                text: "value",
                height: "80px",
                description: "==请选择==",
            })
            $("#FilterId").ComboBox({
                data: [{ "key": "Equal", "value": "等于" }, { "key": "NotEqual", "value": "不等于" }, { "key": "Greater", "value": "大于" }, { "key": "GreaterThan", "value": "大于等于" }, { "key": "Less", "value": "小于" }, { "key": "LessThan", "value": "小于等于" }, { "key": "Null", "value": "为空" }, { "key": "NotNull", "value": "不为空" }, { "key": "Like", "value": "包含" }, { "key": "NotLike", "value": "不包含" }],
                id: "key",
                text: "value",
                height: "100px",
                description: "==请选择==",
            })
            $("#FieldId").ComboBox({
                data: data1,
                id: "key",
                text: "value",
                height: "80px",
                description: "==请选择==",
            })
            if (!!keyValue) {
                debugger;
                Data = top.frames["WorkAuditSettingForm"].$("#gridTable2").jqGridRow()[0];
                $("#Form2").SetWebControls(Data);


            }
        }
        if (Type == 3) {
            $("#panel3").removeAttr("hidden");
            $("#panel1").remove();
            $("#panel2").remove();
            var FieldNameData = top.frames["WorkAuditSettingForm"].top.frames["WorkAuditSetting"].$("#gridTable").jqGrid("getRowData");
            var data1 = [];
            data1.push({
                key: "AuditResult",
                value: "审核意见"
            });
            for (var i = 0; i < FieldNameData.length; i++) {
                if (!!FieldNameData[i].HandleConditionJson) {
                    var HandleConditionJson = JSON.parse(FieldNameData[i].HandleConditionJson)
                    for (var j = 0; j < HandleConditionJson.length; j++) {
                        data1.push({
                            key: HandleConditionJson[j].FieldId,
                            value: HandleConditionJson[j].FieldName
                        });
                    }
                }
            }
            $("#Loginc").ComboBox({
                data: [{ "key": "and", "value": "and" }, { "key": "or", "value": "or" }],
                id: "key",
                text: "value",
                height: "80px",
                description: "==请选择==",
            })
            $("#FilterId").ComboBox({
                data: [{ "key": "Equal", "value": "等于" }, { "key": "NotEqual", "value": "不等于" }, { "key": "Greater", "value": "大于" }, { "key": "GreaterThan", "value": "大于等于" }, { "key": "Less", "value": "小于" }, { "key": "LessThan", "value": "小于等于" }, { "key": "Null", "value": "为空" }, { "key": "NotNull", "value": "不为空" }, { "key": "Like", "value": "包含" }, { "key": "NotLike", "value": "不包含" }],
                id: "key",
                text: "value",
                height: "100px",
                description: "==请选择==",
            })
            $("#FieldId").ComboBox({
                data: data1,
                id: "key",
                text: "value",
                height: "80px",
                description: "==请选择==",
            })
            if (!!keyValue) {
                debugger;
                Data = top.frames["WorkAuditSettingForm"].$("#gridTable2").jqGridRow()[0];
                $("#Form2").SetWebControls(Data); 
            }
            $("#DataFieldId").ComboBox({
                data: [{ "key": "State", "value": "房间状态" }, { "key": "Level", "value": "节点值" }, { "key": "AuditState", "value": "审核状态" }, { "key": "OnlyAudit", "value": "记录审核" }, { "key": "ShowHtml", "value": "是否显示额外操作" }],
                id: "key",
                text: "value",
                height: "130px",
                description: "==请选择==",
            })
            if (!!keyValue) {
                debugger;
                Data = top.frames["WorkAuditSettingForm"].$("#gridTable3").jqGridRow()[0];
                $("#Form3").SetWebControls(Data);

            } else {
                $("#FieldId").val(Id);
            }
        }
    }

    function AcceptClick() {
        debugger;
        if (Type == 1) {
            if (!$('#Form1').Validform()) {
                return false;
            }
            var $gridTable = top.frames["WorkAuditSettingForm"].$("#gridTable1");
            var postData = $("#Form1").GetWebControls("");
            if (!!keyValue) {
                $gridTable.setRowData(keyValue, postData);
            } else {
                $gridTable.addRowData(($gridTable.jqGrid("getRowData").length + 1), postData);
            }
            dialogMsg("操作成功。", 1);
            dialogClose();
        }
        if (Type == 2) {
            if (!$('#Form2').Validform()) {
                return false;
            }
            debugger;
            var $gridTable = top.frames["WorkAuditSettingForm"].$("#gridTable2");
            var postData = $("#Form2").GetWebControls("");
            postData["FieldId"] = $("#FieldId").attr("data-value");
            postData["FieldName"] = $("#FieldId").attr("data-text");
            postData["From"] = Level;
            postData["LogincName"] = $("#Loginc").attr("data-text");
            if (!!keyValue) {
                $gridTable.setRowData(keyValue, postData);
            } else {
                $gridTable.addRowData(($gridTable.jqGrid("getRowData").length + 1), postData);
            }
            dialogMsg("操作成功。", 1);
            dialogClose();
        }
        if (Type == 3) {
            if (!$('#Form3').Validform()) {
                return false;
            }
            debugger;
            var $gridTable = top.frames["WorkAuditSettingForm"].$("#gridTable3");
            var postData = $("#Form3").GetWebControls("");
            postData["FieldName"] = $("#FieldId").attr("data-text");
            postData["FilterName"] = $("#FilterId").attr("data-text");
            postData["LogincName"] = $("#Loginc").attr("data-text");
            postData["DataFieldName"] = $("#DataFieldId").attr("data-text");
            if (!!keyValue) {
                $gridTable.setRowData(keyValue, postData);
            } else {
                $gridTable.addRowData(($gridTable.jqGrid("getRowData").length + 1), postData);
            }
            dialogMsg("操作成功。", 1);
            dialogClose();
        }
    }
</script>
<div class="tab-pane" id="panel1" hidden>
    <table class="form" id="Form1">
        <tr>
            <th class="formTitle">参数名称<font face="宋体">*</font></th>
            <td class="formValue">
                <input id="FieldId" class="form-control" type="hidden" />
                <input id="FieldName" type="text" class="form-control" isvalid="yes" checkexpession="NotNull">
            </td>
        </tr>
        <tr>
            <th class="formTitle">参数类型<font face="宋体">*</font></th>
            <td class="formValue">
                <div id="Type" type="selectTree" class="ui-select" isvalid="yes" checkexpession="NotNull"></div>
            </td>
        </tr>
        <tr>
            <th class="formTitle">是否必填</th>
            <td class="formValue">
                <div id="NeedFlag" type="selectTree" class="ui-select" isvalid="yes" checkexpession="IsScript"></div>
            </td>
        </tr>
    </table>
</div>
<div class="tab-pane" id="panel2" hidden>
    <table class="form" id="Form2">
        <tr>
            <th class="formTitle">条件名称</th>
            <td class="formValue">
                <div id="FieldId" type="selectTree" class="ui-select" isvalid="yes" checkexpession="NotNull"></div>
            </td>
        </tr>
        <tr>
            <th class="formTitle">字段名称</th>
            <td class="formValue">
                <input id="FilterName" type="text" class="form-control" isvalid="yes" checkexpession="NotNull">
            </td>
        </tr>
        <tr>
            <th class="formTitle">排序</th>
            <td class="formValue">
                <input id="Sort" type="number" class="form-control" isvalid="yes" checkexpession="NotNull">
            </td>
        </tr>
        <tr>
            <th class="formTitle">比较</th>
            <td class="formValue">
                <div id="FilterId" type="selectTree" class="ui-select" isvalid="yes" checkexpession="NotNull"></div>
            </td>
        </tr>
        <tr>
            <th class="formTitle">比较值</th>
            <td class="formValue">
                <input id="FilterValue" type="text" class="form-control" isvalid="yes" checkexpession="NotNull">
            </td>
        </tr>
        <tr>
            <th class="formTitle">逻辑</th>
            <td class="formValue">
                <div id="Loginc" type="selectTree" class="ui-select" isvalid="yes" checkexpession="IsScript"></div>
            </td>
        </tr>
        <tr>
            <th class="formTitle">跳转级数</th>
            <td class="formValue">
                <input id="To" type="text" class="form-control" isvalid="yes" checkexpession="NotNull">
            </td>
        </tr>



    </table>
</div>
<div class="tab-pane" id="panel3" hidden>
    <table class="form" id="Form3">
        <tr>
            <th class="formTitle">字段名称</th>
            <td class="formValue">
                <div id="FieldId" type="selectTree" class="ui-select" isvalid="yes" checkexpession="NotNull"></div>
            </td>
        </tr>
        <tr>
            <th class="formTitle">排序</th>
            <td class="formValue">
                <input id="Sort" type="number" class="form-control" isvalid="yes" checkexpession="NotNull">
            </td>
        </tr>
        <tr>
            <th class="formTitle">比较</th>
            <td class="formValue">
                <div id="FilterId" type="selectTree" class="ui-select" isvalid="yes" checkexpession="NotNull"></div>
            </td>
        </tr>
        <tr>
            <th class="formTitle">比较值</th>
            <td class="formValue">
                <input id="FilterValue" type="text" class="form-control" isvalid="yes" checkexpession="NotNull">
            </td>
        </tr>
        <tr>
            <th class="formTitle">逻辑</th>
            <td class="formValue">
                <div id="Loginc" type="selectTree" class="ui-select" isvalid="yes" checkexpession="IsScript"></div>
            </td>
        </tr>
        <tr>
            <th class="formTitle">数据字段</th>
            <td class="formValue">
                <div id="DataFieldId" type="selectTree" class="ui-select" isvalid="yes" checkexpession="IsScript"></div>
            </td>
        </tr>
        <tr>
            <th class="formTitle">数据值</th>
            <td class="formValue">
                <input id="DataFieldValue" type="text" class="form-control" isvalid="yes" checkexpession="NotNull">
            </td>
        </tr>


    </table>
</div>
